home *** CD-ROM | disk | FTP | other *** search
/ PCGUIA 117 / PC Guia 117.iso / Software / Utils / Software6 / Product4 / bandwidth_tester-0.5-fx+mz.xpi / install.js next >
Text File  |  2005-05-03  |  2KB  |  55 lines

  1.  
  2. const gName            = "Bandwidth Tester";
  3. const gAuthor        = "Jeremy Gillick";
  4. const gRegKey        = "/JeremyGillick/BandwidthTest";
  5. const gVersion        = "0.5";
  6. const gJar            = "bandwidthtest.jar";
  7.  
  8. var    error             = null;
  9. var oFolder            = getFolder("Current User", "chrome");
  10. var iContentFlag    = CONTENT | PROFILE_CHROME;
  11. var iLocaleFlag        = LOCALE | PROFILE_CHROME;
  12.  
  13. //Install in App or Profile?
  14. var existsInApplication = File.exists(getFolder(getFolder("chrome"), gJar));
  15. var existsInProfile     = File.exists(getFolder(oFolder, gJar));
  16. if(existsInApplication || (!existsInProfile && !confirm("Do you want to install the extension into your profile folder?\n(Cancel will install into the application folder)")))
  17. {
  18.     iContentFlag    = CONTENT | DELAYED_CHROME;
  19.     iLocaleFlag        = LOCALE | DELAYED_CHROME;
  20.     oFolder         = getFolder("chrome");
  21. }
  22.  
  23. //Uninstall Existing
  24. if(existsInApplication || existsInProfile)
  25.     uninstall(gRegKey);
  26.  
  27. //Init
  28. initInstall(gName, gRegKey, gVersion);
  29. setPackageFolder(oFolder);
  30. error = addFile(gAuthor, gVersion, "chrome/"+ gJar, oFolder, null);
  31.  
  32. //Register
  33. if(error == SUCCESS){
  34.     registerChrome(iContentFlag, getFolder(oFolder, gJar), "content/");
  35.     
  36.     error = performInstall(); //Install
  37.     
  38.     if(error != SUCCESS && error != 999){
  39.         switch(error){
  40.             case -215:
  41.                 alert("The installation of the extension failed.\nOne of the files being overwritten is read-only.");
  42.                 break;
  43.             case -235:
  44.                    alert("The installation of the extension failed.\nThere is insufficient disk space.");
  45.                 break;
  46.             default: 
  47.                 alert("The installation of the extension failed.\nThe error code is: " + error);
  48.         }
  49.         cancelInstall(error);
  50.     }
  51. }
  52. else{
  53.     alert("The installation failed.\n" + error);
  54.     cancelInstall(error);
  55. }